<template>
  <div id="globalSider">
    <a-layout-sider width="200" class="sider" breakpoint="lg" collapsed-width="0">
      <a-menu
        v-model:selectedKeys="current"
        :items="menuItems"
        mode="inline"
        @click="doMenuClick"
      />
    </a-layout-sider>
  </div>
</template>

<script lang="ts" setup>
import { PictureOutlined, UserOutlined } from '@ant-design/icons-vue'
import { h, ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
//菜单列表
const menuItems = [
  {
    key: '/',
    label: '公共图库',
    icon: () => h(PictureOutlined),
  },
  {
    key: '/my_space',
    label: '我的空间',
    icon: () => h(UserOutlined),
  },
]

const current = ref<string[]>([])

router.afterEach((to, from, next) => {
  current.value = [to.path]
})

const doMenuClick = (e: any) => {
  router.push(e.key)
}
</script>

<style lang="scss" scoped>
#globalSider {
  .ant-layout-sider-children {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
}
</style>
